D3 Virtual C++ Compiler Spec
Created 12/12/1998

-----------------------------------------------------
Purpose
-----------------------------------------------------
	Descent 3's scripting language is C/C++ based and is to be compiled by 3rd party 
compilers, from within the editor.  However, since each 3rd party compiler (free or 
commercial) takes different parameters to build a DLL, there has to be a middle layer to 
translate from D3's commands to the compiler's command line options.  Another reason 
for this middle layer is, in order to give an easy interface/front end for the compiler, it has 
to be called from the editor and display the compiler's output in the editor.  However, due 
to a bug in Windows 95/98, a middle layer needs to be implemented in order to handle 
this.  This gives us the opportunity to make a virtual compiler of sorts.

-----------------------------------------------------
How the compiler will be implemented
-----------------------------------------------------
	In order to make an interface callable by Windows 9x and Windows NT, a 
separate, console mode, application has to be made.  This application will get a collection 
of command line parameter, passed in from D3's editor, that gives the requested 
commands and options.  The compiler should translate these options into the compiler's 
options and pass control to the real compiler.  These options and commands will be 
detailed below.  In order for compiler and the virtual compiler's output to be seen in the 
D3 editor, they must output to the stdout of the system.  D3's editor will display all 
output inside the editor.

-----------------------------------------------------
Command Line Options and Commands
-----------------------------------------------------
	The following table displays the command or option that D3 will pass to the compiler 
(on the left column), the description is in the right column.  All command line options are 
case insensitive.

------------------------------------------------------------------------
Compiler Option/Command		Description
------------------------------------------------------------------------
-f filename			Gives the filename (no directory, just a 
				filename) of the source file to be compiled 
				into a DLL.  The filename does not include 
				any spaces. Required option.

-d (coff/c7)			The compiled DLL should include debug 
				information.  The requested debug 
				information type is given, either coff or c7.  
				If this command option is missing, than the 
				DLL should be built without any 
				debugging information.

-o filename			Gives the filename (no directory, just a 
				filename) of the destination DLL.  If this 
				command is missing, than the DLL will 
				have the same name as the source file, only 
				with a DLL extension.

-w 0|1|2|3|4			Specifies the warning level for compiling 
				and linking warnings.  If this command 
				option is missing than it should be set to 3.       

-dir directory			Specifies the directory in which the source 
				file exists and where the output file will go.
		
-level				Compiles the DLL as a level DLL, instead 
				of the default script DLL.  The difference is 
				that a Level DLL includes two more 
				functions to be exported 
				GetTriggerScriptID and GetCOScriptList.  
				Because of this, two .def files will probably 
				be needed.

-----------------------------------------------------
Building A Script In Linux
-----------------------------------------------------
Virtual Compilers are an interface between D3Edit and the compiler.  Since D3Edit is for 
Windows, Virtual Compilers are only needed in Window's executable format.  In order 
to compile a script in Linux (into a shared object), use gcc to compile the script by hand.  
Or, to make it easier, in the bin directory is a script called build_script that can be used to 
build a script in Linux (see the readme for more information).

-----------------------------------------------------
Functions Needed To Be Exported
-----------------------------------------------------
In order for Descent 3 to load a script, a number of functions must be exported, in order 
for Descent 3 to bind to.  The namespace format for these functions is:
_<function name>@<size of parameters in bytes>
Descent 3 can also find the function if it's namespace is in the format:
<function name>
However, you must make sure that the function's calling convention is stdcall.

The following functions must be exported in a level script:
_InitializeDLL@4
_ShutdownDLL@0
_GetGOScriptID@8
_GetTriggerScriptID@8
_GetCOScriptList@8
_CreateInstance@4
_DestroyInstance@8
_CallInstanceEvent@16
_SaveRestoreState@8

The following functions must be exported in a game script (non-level script):
_InitializeDLL@4
_ShutdownDLL@0
_GetGOScriptID@8
_CreateInstance@4
_DestroyInstance@8
_CallInstanceEvent@16
_SaveRestoreState@8
